package com.atfcm.link;

/**
 * @Author whaty
 * @create 2024/10/31 11:01
 */
public class t203移除链表元素 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode nummy =  new ListNode(-1);
        nummy.next = head;

        ListNode cur = nummy;
        while (cur.next != null) {
            if(cur.next.val == val){
                cur.next = cur.next.next;
            }else {
                cur = cur.next;
            }
        }
        return nummy.next;
    }

     static   class ListNode {
        public int val;
        public ListNode next;

        ListNode(int val) {
            this.val = val;
        }
    }
}
